package com.xdy.mdc.activity;

import com.google.android.material.carousel.CarouselLayoutManager;
import com.google.android.material.carousel.CarouselSnapHelper;
import com.xdy.mdc.R;
import com.xdy.mdc.adapter.CarouselAdapter;
import com.xdy.mdc.databinding.ActivityCarouselBinding;

import java.util.ArrayList;

/**
 * carousel_recycler_view
 */
public class CarouselActivity extends BaseViewModelActivity<ActivityCarouselBinding> {

    private CarouselAdapter adapter;

    @Override
    protected void initViews() {
        super.initViews();
        binding.carouselRecyclerView.setLayoutManager(new CarouselLayoutManager());
        binding.carouselRecyclerView2.setLayoutManager(new CarouselLayoutManager());
        new CarouselSnapHelper().attachToRecyclerView(binding.carouselRecyclerView2);
        CarouselLayoutManager carouselLayoutManager_Center = new CarouselLayoutManager();
        carouselLayoutManager_Center.setCarouselAlignment(CarouselLayoutManager.ALIGNMENT_CENTER);
        binding.carouselRecyclerView3.setLayoutManager(carouselLayoutManager_Center);
        new CarouselSnapHelper().attachToRecyclerView(binding.carouselRecyclerView3);
    }

    @Override
    protected void initDatum() {
        super.initDatum();
        adapter = new CarouselAdapter();
        binding.carouselRecyclerView.setAdapter(adapter);
        binding.carouselRecyclerView2.setAdapter(adapter);
        binding.carouselRecyclerView3.setAdapter(adapter);
        ArrayList<Integer> datum = new ArrayList<>();
        datum.add(R.drawable.img_1);
        datum.add(R.drawable.img_2);
        datum.add(R.drawable.img_3);
        datum.add(R.drawable.img_4);
        datum.add(R.drawable.img_5);
        adapter.setDatum(datum);
    }
}